<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <style>
        .layui-card {border:1px solid #f2f2f2;border-radius:5px;}
        .icon {margin-right:10px;color:#1aa094;}
        .icon-cray {color:#ffb800!important;}
        .icon-blue {color:#1e9fff!important;}
        .icon-tip {color:#ff5722!important;}
        .layuimini-qiuck-module {text-align:center;margin-top: 10px}
        .layuimini-qiuck-module a i {display:inline-block;width:100%;height:60px;line-height:60px;text-align:center;border-radius:2px;font-size:30px;background-color:#F8F8F8;color:#333;transition:all .3s;-webkit-transition:all .3s;}
        .layuimini-qiuck-module a cite {position:relative;top:2px;display:block;color:#666;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;font-size:14px;}
        .welcome-module {width:100%;height:210px;}
        .panel {background-color:#fff;border:1px solid transparent;border-radius:3px;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.05);box-shadow:0 1px 1px rgba(0,0,0,.05)}
        .panel-body {padding:10px}
        .panel-title {margin-top:0;margin-bottom:0;font-size:12px;color:inherit}
        .label {display:inline;padding:.2em .6em .3em;font-size:75%;font-weight:700;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;border-radius:.25em;margin-top: .3em;}
        .layui-red {color:red}
        .main_btn > p {height:40px;}
        .layui-bg-number {background-color:#F8F8F8;}
        .layuimini-notice:hover {background:#f6f6f6;}
        .layuimini-notice {padding:7px 16px;clear:both;font-size:12px !important;cursor:pointer;position:relative;transition:background 0.2s ease-in-out;}
        .layuimini-notice-title,.layuimini-notice-label {
            padding-right: 70px !important;text-overflow:ellipsis!important;overflow:hidden!important;white-space:nowrap!important;}
        .layuimini-notice-title {line-height:28px;font-size:14px;}
        .layuimini-notice-extra {position:absolute;top:50%;margin-top:-8px;right:16px;display:inline-block;height:16px;color:#999;}
    </style>
</head>
<body>
<div class="layuimini-container" style="height: 700px">
    <div class="layuimini-main">
            <fieldset class="layui-elem-field">
                <legend>证件修改</legend>
                <div class="layui-field-box">
                    <form class="layui-form layui-form-pane" action="">
                        <div class="layui-form-item">
                            <label class="layui-form-label"><span style="color: red">*</span>姓名</label>
                            <div class="layui-input-inline">
                                <input lay-verify="required" readonly disabled type="text" id="staffName" name="staffName" placeholder="请选择"  lay-verType="tips" autocomplete="off" class="layui-input">
<!--                                <span style="position: relative;top: -26px;left: 10px;color: #8D8D8D" class="fa fa-search"></span>-->
                            </div>
                            <label class="layui-form-label"><span style="color: red">*</span>证件类型</label>
                            <div class="layui-input-inline">
                                <select id="type" name="type" lay-verify="required">
                                    <option value="">请选择</option>
                                    <option value="职业资格证">职业资格证</option>
                                    <option value="行业资格证">行业资格证</option>
                                    <option value="职称证">职称证</option>
                                    <option value="其它">其它</option>
                                </select>
                            </div>
                            <label class="layui-form-label">证件编号</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="credentialNumber" id="credentialNumber">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">发证机构</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="certifyingAuthority" id="certifyingAuthority">
                            </div>
                            <label class="layui-form-label">生效日期</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="validTime" id="validTime" placeholder="yyyy-mm-dd" lay-verify="required|date">
                            </div>
                            <label class="layui-form-label">到期日期</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="expireTime" id="expireTime" placeholder="yyyy-mm-dd" lay-verify="required|date">
                            </div>

                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">备注</label>
                            <div class="layui-input-block">
                                <textarea style="width: 808px" name="remark" id="remark"  placeholder="请输入内容" class="layui-textarea"></textarea>
                            </div>
                        </div>
                        <br>
                        <br>
                        <br>
                        <div style="float: right" class="layui-form-item">
                            <button class="layui-btn" lay-submit="" lay-filter="demo2">提交</button>
                            <button class="layui-btn layui-btn-primary" id="cancelBtn">取消</button>
                        </div>
                    </form>
                </div>
            </fieldset>
    </div>
</div>
<script src="../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="../../lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>
<script src="../../js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script src="../../js/userAuth.js"></script>
<script>
    var rowData;
    layui.use(['layer', 'form','miniTab'], function() {
        var form = layui.form,
            layer = layui.layer,
            miniTab = layui.miniTab;
        $("#staffName").click(function() {
            var index = layer.open({
                title: '搜索',
                type: 2,
                shade: 0.2,
                maxmin:true,
                shadeClose: true,
                area: ['70%', '100%'],
                content: 'staffQuery.html',
                end :function() {
                    rowData = JSON.parse(sessionStorage.getItem("rowData"));
                    $("#staffName").val(rowData.staffName);
                }
            });
        })
        //当你需要使用ajax提交表单时,可监听表单提交
        //立即提交按钮要设置lay-submit属性,才能被监听
        //submit(formDemo) 表示只监听 含有lay-filter="formDemo" 的按钮
        form.on('submit(demo2)', function(data) {
            //data.field 是一个json对象,批量获取表单的值{'表单的name':'对应的值'}
            data.field.credentialId = rowData2.credentialId;
            console.log("data="+JSON.stringify(data.field))
            $.ajax({
                url:'/credential/updateById',
                method:'post',
                contentType:"application/json;charset=utf-8",
                datatype:"text",
                data:JSON.stringify(data.field),
                success : function(response) {
                    layer.msg("修改成功！");
                    setTimeout(function (){
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.location.reload(); //刷新父页面
                        parent.layer.close(index);//关闭当前页
                    }, 800);

                },
                error : function(response) {
                    layer.msg(response.msg)
                }
            })
            //return false 可以阻止 表单提交(刷新页面)
            return false;
        });
    })
    $("#cancelBtn").click(function() {
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);//关闭当前页
    })
    //日期选择器渲染
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        //常规用法
        laydate.render({
            elem: '#validTime',
        });
        laydate.render({
            elem: '#expireTime'
        });

    });
</script>
<!--初始化填充数据-->
<script>
    let rowData2 = JSON.parse(sessionStorage.getItem("rowData2"))
    console.log(rowData2) //得到当前行数据
    $('input[name="staffName"]').val(rowData2.staff.staffName);
    $('select[name="type"]').val(rowData2.type);
    $('input[name="credentialNumber"]').val(rowData2.credentialNumber);
    $('input[name="certifyingAuthority"]').val(rowData2.certifyingAuthority);
    $('input[name="validTime"]').val(rowData2.validTime);
    $('input[name="expireTime"]').val(rowData2.expireTime);
    $('textarea[name="remark"]').val(rowData2.remark);
</script>
</body>
</html>
